﻿<%@ Page Language="C#" Title="路段划分页面" MasterPageFile="~/W_View/PageMaster.Master" CodeBehind="B_InvntoryPage.aspx.cs" Inherits="STHPMS1.Web.W_View.Basis.B_InvntoryPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <%= UiHelper.RefJsFileHtml("/Scripts/TypeScript/Enum.js")%>
    <%= UiHelper.RefJsFileHtml("/Scripts/TypeScript/JsPage.js")%>
    <%= UiHelper.RefJsFileHtml("/Scripts/TypeScript/Appearance.js")%>
    <%= UiHelper.RefJsFileHtml("/Scripts/TypeScript/Bussiness.js")%>

     <script type="text/javascript">

         var _view = new JsPage();
         var _viewSeg = new JsPage();

         var _css = new Appearance();
         var _bus = new Bussiness();

         function onDivisionClick() {
             var row = $('#dg').datagrid('getSelected');
             if (row) {
                 if (row.Change_Ornot) {
                     $.messager.progress({
                         title: '请等待',
                         msg: '加载数据中...'
                     });

                     $.ajax({
                         type: 'post',
                         async: false,
                         url: '/api/invntory?rdwayid='+row.Rdwayid,
                         cache: false,
                         complete: function () {
                             $.messager.progress('close');
                         },
                         success: function (thicks) {
                             $('#dg').datagrid('reload');
                         },
                         error: Common.ShowError
                     });
                 } else {
                     $.messager.alert('消息提示', '该路线没有发生变化，不进行路段划分', 'warning');
                 }
             } else {
                 $.messager.alert('消息提示', '请选择一条路线进行路段划分!', 'warning');
             }
         }
         function onSegEditClick() {
             var row = $('#dg').datagrid('getSelected');
             if (row)
             {
                 $('#cmbSegRdwayid').combobox('setValue', row.Rdwayid);
                 var data = EnumEx.getDicts(DirectionEnum, function (id) { return true;});
                 if (data) {
                     $('#cmbSegDirection').combobox("loadData", data).combobox('select', data[0].id);
                 }
                 $("#dlgSeg").dialog("open");
             }
             else {
                 $.messager.alert('消息提示', '请选择一条路线!', 'warning');
             }
         }

         function onUnitEditClick() {
             var row = $('#dg').datagrid('getSelected');
             if (row) {
                 $('#cmbUnitRdwayid').combobox('setValue', row.Rdwayid);
                 var data = EnumEx.getDicts(DirectionEnum, function (id) { return true; });
                 if (data) {
                     $('#cmbUnitDirection').combobox("loadData", data).combobox('select', data[0].id);
                 }
                 $("#dlgUnit").dialog("open");
             }
             else {
                 $.messager.alert('消息提示', '请选择一条路线!', 'warning');
             }
         }
         function onSegCancelClick() {
             $("#dlgSeg").dialog("close");
        }
         function onUnitCancelClick1() {
             $("#dlgUnit").dialog("close");
        }

         function change_seg(record) {
             var rdwaryid=$('#cmbSegRdwayid').combobox('getValue');
             var direction_id = $('#cmbSegDirection').combobox('getValue');
             if (rdwaryid && direction_id)
                _viewSeg.setDataGrid($('#dgSeg')).loadDataGrid("/api/invntory/seg?rdwaryid=" + rdwaryid + "&direction_id=" + direction_id);
         }

         function change_unit(record) {
             var rdwaryid = $('#cmbUnitRdwayid').combobox('getValue');
             var direction_id = $('#cmbUnitDirection').combobox('getValue');
             if (rdwaryid && direction_id)
                 _viewSeg.setDataGrid($('#dgUnit')).loadDataGrid("/api/invntory/unit?rdwaryid=" + rdwaryid + "&direction_id=" + direction_id);
         }


        $(function () {
            $("#btnDivision").on("click", onDivisionClick);
            $("#btnSegEdit").on("click", onSegEditClick);
            $("#btnUnitEdit").on("click", onUnitEditClick);
            $("#btnSegCancel").on("click", onSegCancelClick);
            $("#btnUnitCancel").on("click", onUnitCancelClick1);
            $("#cmbSegDirection").combobox({ onSelect: change_seg });
            $("#cmbUnitDirection").combobox({ onSelect: change_unit });
            
            _view.setDataGrid($('#dg')).loadDataGrid("/api/invntory");
            _css.loadAdmDiv();
        });
    </script>    

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    
   
    <div id="tb">
        <a id="btnDivision" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" >路段划分</a>
        <a id="btnSegEdit"  href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" >路段查看</a>
        <a id="btnUnitEdit"  href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" >单元查看</a>
    </div>

     <div id="dlg-buttons">
		<a id="btnSegCancel" href="javascript:void(0)" class="easyui-linkbutton" >取消</a>
	</div>

    <div id="dlg-buttons1">
		<a id="btnUnitCancel" href="javascript:void(0)" class="easyui-linkbutton" >取消</a>
	</div>

    <table id="dg" class="easyui-datagrid content-place"  data-ajaxcached="false"  data-options='{
                  "title": "路线划分结果",
                  "toolbar": "#tb",
                  "method": "get",
                  "iconCls": "icon-edit",
                  "width": "auto",
                  "height": "auto",
                  "nowrap": false,
                  "striped": true,
                  "border": true,
                  "collapsible": false,
                  "fit": false,
                  "singleSelect": true,
                  "rownumbers": true,
                  "pagination": true
                }' >
        <thead>
            <tr>
                <th data-options="field:'Rdwayid',editor:'text',width:80,align:'center'">路线编号</th>
                <th data-options="field:'Name',editor:'text',width:160,align:'center' ">路线名称</th>
                <th data-options="field:'SegCount',editor:'numberbox',width:120,align:'center'">路段数量</th>
                <th data-options="field:'UnitCount',editor:'numberbox',width:120,align:'center'">单元数量</th>
                <th data-options="field:'Change_Ornot',editor:'numberbox',width:80,align:'center',formatter:function(val){return val?'有':'无';} " >是否变动</th>
            </tr>
        </thead>
    </table>

    <div id="dlgSeg" class="easyui-dialog" title="路段" style="width:800px;height:560px;padding:10px" data-options="
                closed:true,
				iconCls: 'icon-save',
				buttons: '#dlg-buttons'
			">

          <table id="dgSeg" class="easyui-datagrid content-place" data-ajaxcached="false"  data-options='{
                  "toolbar": "#tbSeg",
                  "method": "get",
                  "iconCls": "icon-edit",
                  "width": "auto",
                  "height": "auto",
                  "nowrap": false,
                  "striped": true,
                  "border": true,
                  "collapsible": false,
                  "fit": false,
                  "singleSelect": true,
                  "rownumbers": true,
                  "pagination": true
                }' >
            <thead>
                <tr>
                    <th data-options="field:'Segid',editor:'text',width:80,align:'center',hidden:true">路段</th>
                    <th data-options="field:'Name',editor:'text',width:80,align:'center' ">名称</th>
                    <th data-options="field:'Rdwayid',editor:'text',width:80,align:'center',hidden:true ">路线编号</th>
                    <th data-options="field:'Beginmp',editor:'numberbox',width:80,align:'center',formatter:_css.formatStake ">起点桩号</th>
                    <th data-options="field:'Endmp',editor:'numberbox',width:80,align:'center' ,formatter:_css.formatStake">终点桩号</th>
                    <th data-options="field:'Direction_Dictid',editor:'numberbox',width:80,align:'center',formatter:formatEnum  ">行车方向</th>
                    <th data-options="field:'Admdiv',editor:'numberbox',width:80,align:'center' ,formatter:_css.formatAdmdiv ">行政区域</th>
                    <th data-options="field:'Manaut',editor:'text',width:80,align:'center' ">管养单位</th>
                    <th data-options="field:'Pvmttype_Dictid',editor:'numberbox',width:80,align:'center',formatter:formatEnum  ">面层类型</th>
                    <th data-options="field:'Basictype_Dictid',editor:'numberbox',width:80,align:'center',formatter:formatEnum  ">基层类型</th>
                    <th data-options="field:'Numlanes',editor:'numberbox',width:80,align:'center' ">车道数</th>
                    <th data-options="field:'Surfwidth',editor:'numberbox',width:80,align:'center' ">路面宽度（m）</th>
                    <th data-options="field:'Sltp_Dictid',editor:'numberbox',width:80,align:'center',formatter:formatEnum  ">土基类型</th>
                    <th data-options="field:'Should_Dictid',editor:'numberbox',width:80,align:'center' ,formatter:formatEnum ">路肩类型</th>
                    <th data-options="field:'Admgrd',editor:'numberbox',width:80,align:'center' ,formatter:formatEnum ">行政等级</th>
                    <th data-options="field:'Rdclass_Dictid',editor:'numberbox',width:80,align:'center' ,formatter:formatEnum ">技术等级</th>
                    <th data-options="field:'Shldwidth',editor:'numberbox',width:80,align:'center',hidden:true">路肩宽度(m)</th>
                    <th data-options="field:'Cubexp_Dictid',editor:'numberbox',width:80,align:'center',hidden:true ">路缘石类型</th>
                    <th data-options="field:'Median',editor:'text',width:80,align:'center',hidden:true ">中间分隔带</th>
                    <th data-options="field:'Fromloc',editor:'text',width:80,align:'center',hidden:true ">起点位置</th>
                    <th data-options="field:'Toloc',editor:'text',width:80,align:'center' ,hidden:true">终点位置</th>
                    <th data-options="field:'Mapobjectid',editor:'text',width:80,align:'center' ,hidden:true">路段地图标号</th>
                    <th data-options="field:'Begindate',editor:'datebox',width:80,align:'center' ,formatter:_css.formatDate">通车时间</th>
                    <th data-options="field:'Modelgroup_Pci',editor:'text',width:80,align:'center',hidden:true ">PCI模型组ID</th>
                    <th data-options="field:'Modelgroup_Pssi',editor:'text',width:80,align:'center',hidden:true ">PSSI模型组ID</th>
                    <th data-options="field:'Modelgroup_Pqi',editor:'text',width:80,align:'center' ,hidden:true">PQI模型组ID</th>
                    <th data-options="field:'Importdate',editor:'datebox',width:80,align:'center',formatter:_css.formatDate ">修改时间</th>
                    <th data-options="field:'Comments',editor:'text',width:80,align:'center',hidden:true ">注释</th>
                    <th data-options="field:'His_Version',editor:'numberbox',width:80,align:'center',hidden:true ">最新养护版本号</th>
                </tr>
            </thead>
        </table>

        <div id="tbSeg">
            <select id="cmbSegRdwayid" class="easyui-combobox" style="width:100px" data-options="readonly:true,prompt:'路线名称',url:'/api/roadway/all',method:'get',valueField:'Rdwayid',textField:'Name',panelHeight:'auto'">
            </select>
            <select id="cmbSegDirection" class="easyui-combobox" style="width:100px" data-options="prompt:'行车方向',valueField:'id',textField:'text',panelHeight:'auto'">
            </select>
        </div>

    </div>

     <div id="dlgUnit" class="easyui-dialog" title="单元" style="width:500px;height:430px;padding:10px" data-options="
                closed:true,
				iconCls: 'icon-save',
				buttons: '#dlg-buttons1'
			">
          <table id="dgUnit" class="easyui-datagrid content-place" data-ajaxcached="false"  data-options='{
                  "toolbar": "#tbUnit",
                  "method": "get",
                  "iconCls": "icon-edit",
                  "width": "auto",
                  "height": "auto",
                  "nowrap": false,
                  "striped": true,
                  "border": true,
                  "collapsible": false,
                  "fit": false,
                  "singleSelect": true,
                  "rownumbers": true,
                  "pagination": true
                }' >
            <thead>
                <tr>
                    <th data-options="field:'Unit',editor:'text',width:80,align:'center',hidden:true ">单元</th>
                    <th data-options="field:'Name',editor:'text',width:200,align:'center' ">名称</th>
                    <th data-options="field:'Beginmp',editor:'numberbox',width:100,align:'center' ,formatter:_css.formatStake ">起点桩号</th>
                    <th data-options="field:'Endmp',editor:'numberbox',width:100,align:'center' ,formatter:_css.formatStake ">终点桩号</th>
                    <th data-options="field:'Rdwayid',editor:'text',width:80,align:'center',hidden:true ">路线编号</th>
                    <th data-options="field:'Direction_Dictid',editor:'numberbox',width:80,align:'center',formatter:formatEnum ,hidden:true ">行车方向</th>
                    <th data-options="field:'Comments',editor:'text',width:80,align:'center' ,hidden:true ">注释</th>
                    <th data-options="field:'His_Version',editor:'numberbox',width:80,align:'center',hidden:true ">最新养护版本号</th>
                </tr>
            </thead>
        </table>
         
        <div id="tbUnit">
            <select id="cmbUnitRdwayid" class="easyui-combobox" style="width:100px" data-options="readonly:true,prompt:'路线名称',url:'/api/roadway/all',method:'get',valueField:'Rdwayid',textField:'Name',panelHeight:'auto'">
            </select>
            <select id="cmbUnitDirection" class="easyui-combobox" style="width:100px" data-options="prompt:'行车方向',valueField:'id',textField:'text',panelHeight:'auto'">
            </select>
        </div>
    </div>

</asp:Content>
